/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __ATC_UICOMPONENTBUILDER_HDR__
#define __ATC_UICOMPONENTBUILDER_HDR__


#include <stdexcept>

#include <qobject.h>


class QWidget;


namespace xml {
	class  Document;
	struct DocumentNode;
}


namespace pact {

	class BaseQuestion;
	class ChoiceQuestion;
	class BaseScaleQuestion;
	class ScaleQuestion;
	class MultiQuestion;
	class ValidatedQuestion;

	/*!
	 * \struct pact::uicomponentbuilder_error
	 */
	struct uicomponentbuilder_error : public std::runtime_error{
		uicomponentbuilder_error(const std::string& msg) 
			:std::runtime_error(msg){}
	};


	/*!
	 * \class pact::UIComponentBuiler
	 */
	class UIComponentBuilder : public QObject {
		Q_OBJECT

	public:
        static QWidget* build( 		
				const xml::Document *,
				const xml::DocumentNode *, 
				QWidget * 
			);

	private:
		static QWidget* build_question( 
				const xml::Document *,
				const xml::DocumentNode *, 
				QWidget *,
				const std::string &
			);
		static void process_properties( 
				const xml::Document *,
				const xml::DocumentNode *, 
				QWidget *
			);
		static void process_base_question(
				const xml::Document *,
				const xml::DocumentNode *,
				BaseQuestion *
			);
		static void process_choice_question(
				const xml::Document *,
				const xml::DocumentNode *,
				ChoiceQuestion *
			);
		static void process_base_scale_question(
				const xml::Document *,
				const xml::DocumentNode *,
				BaseScaleQuestion *
			);
		static void process_scale_question(
				const xml::Document *,
				const xml::DocumentNode *,
				ScaleQuestion *
			);
		static void process_multi_question(
				const xml::Document *,
				const xml::DocumentNode *,
				MultiQuestion *
			);
		static void process_validated_question(
				const xml::Document *,
				const xml::DocumentNode *,
				ValidatedQuestion *
			);
		

	private:
        virtual ~UIComponentBuilder() {};

	};

};


#endif
